<!DOCTYPE html>
<html>
<head>
<title>简单计算器</title>
<script>
function calculate() {
    var num1 = parseFloat(document.getElementById('num1').value);
    var num2 = parseFloat(document.getElementById('num2').value);
    var operator = document.getElementById('operator').value;
    var result;

    switch (operator) {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - num2;
            break;
        case '*':
            result = num1 * num2;
            break;
        case '/':
            if (num2 != 0) {
                result = num1 / num2;
            } else {
                result = '除数不能为0';
            }
            break;
        default:
            result = '无效的运算符';
            break;
    }

    document.getElementById('result').value = result;
}
</script>
</head>
<body>

<h2>简单计算器</h2>

<label for="num1">数字 1:</label>
<input type="number" id="num1" name="num1">
<br><br>

<label for="num2">数字 2:</label>
<input type="number" id="num2" name="num2">
<br><br>

<label for="operator">运算符:</label>
<select id="operator" name="operator">
  <option value="+">加</option>
  <option value="-">减</option>
  <option value="*">乘</option>
  <option value="/">除</option>
</select>
<br><br>

<button onclick="calculate()">计算</button>
<br><br>

<label for="result">结果:</label>
<input type="text" id="result" name="result" readonly>
<br><br>

</body>
</html>

